![]() |
Kinetis SDK API Reference Manual
1.0.0-beta
Freescale Semiconductor, Inc.
|
The section describes the programming interface of the SAI Peripheral driver. More...
Data Structures | |
| struct | sai_user_config_t |
| The description structure for the SAI TX/RX module. More... | |
| struct | sai_data_format_t |
| Defines the PCM data format. More... | |
| struct | sai_handler_t |
| The SAI handler structure. More... | |
Macros | |
| #define | USEDMA 1 |
| Use DMA mode or interrupt mode. More... | |
Typedefs | |
| typedef void(* | sai_callback_t )(void *parameter) |
| SAI callback function. | |
Enumerations | |
| enum | sai_status_t { kStatus_SAI_Success = 0U, kStatus_SAI_Fail = 1U, kStatus_SAI_DeviceBusy = 2U } |
| Status structure for SAI. | |
Functions | |
| sai_status_t | sai_init (sai_handler_t *handler, sai_user_config_t *config) |
| Initializes the SAI module. More... | |
| sai_status_t | sai_deinit (sai_handler_t *handler) |
| De-initializes the SAI module. More... | |
| sai_status_t | sai_configure_data_format (sai_handler_t *handler, sai_data_format_t *format) |
| Configures the PCM data format. More... | |
| void | sai_start_read_data (sai_handler_t *handler) |
| Starts reading data from FIFO. More... | |
| void | sai_start_write_data (sai_handler_t *handler) |
| Starts writing data to FIFO. More... | |
| static void | sai_stop_read_data (sai_handler_t *handler) |
| Stops reading data from FIFO, mainly to disable the DMA or the interrupt request bit. More... | |
| static void | sai_stop_write_data (sai_handler_t *handler) |
| Stop write data to FIFO, mainly to disable the DMA or the interrupt request bit. More... | |
| static void | sai_clear_tx_status (sai_handler_t *handler) |
| Clears the TX FIFO error flag. More... | |
| static void | sai_clear_rx_status (sai_handler_t *handler) |
| Clears the RX FIFO error flag. More... | |
| static uint32_t * | sai_get_fifo_address (sai_handler_t *handler) |
| Gets the FIFO address of the data channel. More... | |
| uint32_t | sai_send_data (sai_handler_t *handler, uint8_t *addr, uint32_t len) |
| Sends a certain length data. More... | |
| uint32_t | sai_receive_data (sai_handler_t *handler, uint8_t *addr, uint32_t len) |
| Receives a certain length data. More... | |
| void | sai_register_callback (sai_handler_t *handler, sai_callback_t callback, void *callback_param) |
| Registers the callback function after a transfer. More... | |
| struct sai_user_config_t |
Data Fields | |
| sai_mclk_source_t | mclk_source |
| Master clock source. More... | |
| bool | mclk_divide_enable |
| Enable the divide of master clock to generate bit clock. More... | |
| sai_sync_mode_t | sync_mode |
| Synchronous or asynchronous. More... | |
| sai_bus_t | bus_type |
| I2S left, I2S right or I2S type. More... | |
| sai_master_slave_t | slave_master |
| Master or slave. More... | |
| sai_bclk_source_t | bclk_source |
| Bit clock from master clock or other modules. More... | |
| uint8_t | channel |
| Which FIFO is used to transfer. More... | |
| sai_mclk_source_t sai_user_config_t::mclk_source |
| bool sai_user_config_t::mclk_divide_enable |
| sai_sync_mode_t sai_user_config_t::sync_mode |
| sai_bus_t sai_user_config_t::bus_type |
| sai_master_slave_t sai_user_config_t::slave_master |
| sai_bclk_source_t sai_user_config_t::bclk_source |
| uint8_t sai_user_config_t::channel |
| struct sai_data_format_t |
Data Fields | |
| uint32_t | sample_rate |
| Sample rate of the PCM file. | |
| uint32_t | mclk |
| Master clock frequency. | |
| uint8_t | bits |
| How many bits in a word. | |
| uint8_t | words |
| How many word in a frame. | |
| uint8_t | watermark |
| When to send interrupt/DMA request. | |
| struct sai_handler_t |
The structure is used in the SAI runtime.
Data Fields | |
| uint8_t | instance |
| SAI instance. | |
| bool | direction |
| RX or TX. | |
| uint8_t | fifo_channel |
| Which data channel is used. | |
| #define USEDMA 1 |
| sai_status_t sai_init | ( | sai_handler_t * | handler, |
| sai_user_config_t * | config | ||
| ) |
This function initializes the SAI registers according to the configuration structure. This function initializes the basic settings for SAI, including some board relevant settings. Notice: This function does not initialize an entire SAI instance. This function only initializes the TX or RX according to the value in the handler.
| handler | SAI handler structure pointer. |
| config | The configuration structure of SAI. |
| sai_status_t sai_deinit | ( | sai_handler_t * | handler | ) |
This function closes the SAI device. It does not close the entire SAI instance. It only closes the TX or RX according to the value in the handler.
| handler | SAI handler structure pointer of the SAI module. |
| sai_status_t sai_configure_data_format | ( | sai_handler_t * | handler, |
| sai_data_format_t * | format | ||
| ) |
The function mainly configures an audio sample rate, data bits and a channel number.
| handler | SAI handler structure pointer of the SAI module. |
| format | PCM data format structure pointer. |
| void sai_start_read_data | ( | sai_handler_t * | handler | ) |
The function enables the interrupt/DMA request source and enables the transmit channel.
| handler | SAI handler structure pointer of the SAI module. |
| void sai_start_write_data | ( | sai_handler_t * | handler | ) |
The function enables the interrupt/DMA request source and enables the receive channel.
| handler | SAI handler structure pointer of the SAI module. |
|
inlinestatic |
This function provides the method to pause receiving data.
| handler | SAI handler structure pointer of the SAI module. |
|
inlinestatic |
This function provides the method to pause writing data.
| handler | SAI handler structure pointer of the SAI module. |
|
inlinestatic |
| handler | SAI handler structure pointer of the SAI module. |
|
inlinestatic |
| handler | SAI handler structure pointer of the SAI module. |
|
inlinestatic |
This function is mainly used for the DMA settings, which the DMA configuration needs for the source/destination address of SAI.
| handler | SAI handler structure pointer of the SAI module. |
| uint32_t sai_send_data | ( | sai_handler_t * | handler, |
| uint8_t * | addr, | ||
| uint32_t | len | ||
| ) |
This function sends the data to the TX FIFO. This function starts the transfer, and while finishing the transfer, it calls the callback function registered by users.
| handler | SAI handler structure pointer of the SAI module. |
| addr | Address of the data which needs to be transferred. |
| len | The data length which need to be sent. |
| uint32_t sai_receive_data | ( | sai_handler_t * | handler, |
| uint8_t * | addr, | ||
| uint32_t | len | ||
| ) |
This function receives the data from the RX FIFO. This function starts the transfer, and while finishing the transfer, it calls the callback function registered by users.
| handler | SAI handler structure pointer of the SAI module. |
| addr | Address of the data which needs to be transferred. |
| len | The data length which needs to be received. |
| void sai_register_callback | ( | sai_handler_t * | handler, |
| sai_callback_t | callback, | ||
| void * | callback_param | ||
| ) |
This function tells SAI which function needs to be called after a period length transfer.
| handler | SAI handler structure pointer of the SAI module. |
| callback | Callback function defined by users. |
| callback_param | The parameter of the callback function. |